﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FlowerModel;
using FlowerDAL;

namespace FlowerBLL
{
    public class FlowersBLL
    {
        #region 花卉购买方法
        /// <summary>
        /// 花卉购买方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public List<T> GetFlowers<T>()
        {
            return BllFactory.NewFlowersDAL().GetFlowers<T>();
        }

        #endregion

        #region 添加花卉
        /// <summary>
        /// 添加花卉
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="flo"></param>
        /// <returns></returns>
        public bool AddStock1<T>(T flo)
        {
            return BllFactory.NewFlowersDAL().AddStock1<T>(flo);
        }

        #endregion

        #region 花卉修改状态
        /// <summary>
        /// 花卉修改状态
        /// </summary>
        /// <param name="state"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public int UpdateStateFlowers(int state, int id)
        {
            return BllFactory.NewFlowersDAL().UpdateStateFlowers(state, id);
        }
        #endregion

        #region 修改方法

        /// <summary>
        /// 修改方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="flo"></param>
        /// <returns></returns>
        public bool PurchaseStock<T>(T flo)
        {
            return BllFactory.NewFlowersDAL().PurchaseStock<T>(flo);
        }
        #endregion

        #region 反填数据

        /// <summary>
        /// 反填数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        public T GetStock<T>(int id)
        {
            return BllFactory.NewFlowersDAL().GetStock<T>(id);
        }

        #endregion

        #region 按花的种类条件查询

        /// <summary>
        /// 按花的种类条件查询
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Parameter"></param>
        /// <returns></returns>
        public List<T> GetStockList<T>(params System.Data.SqlClient.SqlParameter[] Parameter)
        {
            return BllFactory.NewFlowersDAL().GetStockList<T>(Parameter);
        }

        #endregion

        #region 统计价钱

        //统计总价
        public int GetMoney()
        {
            return BllFactory.NewFlowersDAL().GetMoney();
        }

        //按编号统计价钱
        public int GetXqMoney(int? StockId)
        {
            return BllFactory.NewFlowersDAL().GetXqMoney(StockId);
        }

        #endregion

        #region 采购订单显示

        public List<FlowersMasters> Getlist()
        {
            return BllFactory.NewFlowersDAL().Getlist();
        }

        #endregion

        #region 批量修改
        //批量修改FlowersMasters表的StockId字段
        public int UpdateFlowers(int stockid, string str)
        {
            return BllFactory.NewFlowersDAL().UpdateFlowers(stockid, str);
        }

        public int UpdateNum(List<Flowers> list, string flowername, string num)
        {
            return BllFactory.NewFlowersDAL().UpdateNum(list, flowername, num);
        }

        #endregion

        #region 获取进货订单的订单号
        //获取进货订单的订单号
        public string GetStockId()
        {
            return BllFactory.NewFlowersDAL().GetStockId();
        }
        #endregion

        /// <summary>
        /// 添加购物车
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int AddMyCar(int id)
        {
            return BllFactory.NewFlowersDAL().AddMyCar(id);
        }
        /// <summary>
        /// 购物车显示
        /// </summary>
        /// <returns></returns>
        public List<MyCar> MyCarList()
        {
            return BllFactory.NewFlowersDAL().MyCarList();
        }
        /// <summary>
        /// 通过id查询出购买数量
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int UpdateNum(int id)
        {
            return BllFactory.NewFlowersDAL().UpdateNum(id);
        }
        /// <summary>
        /// 修改库存
        /// </summary>
        /// <param name="buy"></param>
        /// <returns></returns>
        public int UpdateKNum(MyCar my)
        {
            return BllFactory.NewFlowersDAL().UpdateKNum(my);
        }
        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int AddOrder(int? id)
        {
            return BllFactory.NewFlowersDAL().AddOrder(id);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Delete<T>(int id)
        {
            return BllFactory.NewFlowersDAL().Delete<T>(id);
        }
    }
}
